package com.example.demo.service;

import com.example.demo.mapper.UserMapper;
import com.example.demo.model.Log;
import com.example.demo.model.User;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
@Service
public class UserService {
    @Resource
    private UserMapper userMapper;
    @Resource
    private LogService logService;

    @Transactional(propagation = Propagation.REQUIRED)
    public int save(User user) {
        int result = userMapper.save(user);
        logService.saveLog("用户插入: " + user.getUsername());
        return result;
    }
}
